#include "mainoptions.h"
#include "mainapp.h"

#include <QString>
#include <QSettings>
#include <QLocale>
//

MainOptions::MainOptions(  )
		: QObject(),
		m_options() {}
//



void MainOptions::Save() {
	QSettings set ( MainApp::getAppDir() + "main.ini", QSettings::IniFormat );
	foreach ( QString key, m_options.keys() )
	set.setValue ( key, m_options.value ( key ) );
}


void MainOptions::Default() {
	m_options["emerge"] = "emerge";

	QString lang = QLocale::languageToString ( QLocale::system().language() );
	if ( lang.toLower() == "c" ) m_options["lang"] = "English";
	else m_options["lang"] = lang;
}


void MainOptions::Load() {
	QSettings set ( MainApp::getAppDir() + "main.ini", QSettings::IniFormat );
	foreach ( QString key, set.allKeys() )
	m_options[key] = set.value ( key );

	MainApp::setTranslation ( m_options["lang"].toString() );
}

